<template>
  <div>
    <a-input disabled v-model="curValue" placeholder="客户选择" style="width:85%"></a-input>
    <a-button
      :disabled="disabled"
      @click="handleOpenChoose"
      slot="suffix"
      style="width:15%"
      class="searchBtn"
      type="primary"
    >
      <a-icon class="colour" type="search"/>
    </a-button>
    <ListChoose ref="supplierChoose" @onChoose="handleChoose"></ListChoose>
  </div>
</template>
<script>
import ListChoose from './ListChoose.vue'

export default {
  props: {
    value: { type: [String, Object], required: false },
    disabled: { type: Boolean, required: false, default: false }
  },
  components: {
    ListChoose
  },
  data () {
    return {
      curValue: '',
      keyword: '',
      RealName: '',
      timeout: null,
      dataSource: []
    }
  },
  watch: {
    value (value) {
      this.curValue = value
      if (this.dataSource.length === 0) {
        if (value) {
          this.dataSource = [...value]
        } else {
          this.dataSource = []
        }
      }
    },
    curValue (n, o) {
      if (n) {
      }
    }
  },
  mounted () {
    this.curValue = this.value
  },
  methods: {
    changeuser () {
    },
    handleSearch (value) {
      this.reload(value)
    },
    handleOpenChoose () {
      this.$refs.supplierChoose.openChoose()
    },
    handleChoose (selectedRows) {
      // console.log(selectedRows)
      // this.$http
      //   .post(
      //     '/CustomerManagement/Cust_CustomerAllocation/GetUserInfoByCustomerId?CustomerId=' + selectedRows[0].cCusCode
      //   )
      //   .then(resJson => {
      //     //console.log('res', resJson)
      //     // this.RealName = resJson.Data.RealName
      //     //console.log(this.RealName)
      //   })
      // this.$emit('onname', this.RealName)
      this.dataSource = [...selectedRows]
      var row = selectedRows[0]
      this.curValue = row.cCusName
      this.$emit('input', this.curValue)
      this.$emit('closeMode', row)
    }
  }
}
</script>

<style>
.searchBtn {
  vertical-align: baseline;
}

.colour {
  color: #fff;
}
</style>
